import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;

public class Test05 {
    public static void main(String[] args) {
        ArrayList<String> list=new ArrayList<>();
        Collections.addAll(list,"张无忌","周芷若","张强","张三丰","张良","王二麻子");
       /* list.stream().filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {

                return s.startsWith("张");

            }
        }).forEach(new Consumer<String >(){
            @Override
            public void accept(String s){
                System.out.println(s);
            }

        });*/
//        list.stream().filter(s->s.startsWith("张")).forEach(s->System.out.println(s));
        list.stream().limit(3)
                .forEach(s->System.out.println(s));
        System.out.println("============");
        list.stream()
                .skip(4)
                .forEach(s->System.out.println(s));
        System.out.println("============");
        list.stream().skip(3)
                .limit(3)
                .forEach(s->System.out.println(s));
        ArrayList<String> list1=new ArrayList<>();
        Collections.addAll(list1,"张无忌","张无忌","张强","张三丰","张翠山","张良","王二麻子");
        list1.stream().distinct().forEach(s->System.out.println(s));
        /*Stream().concat(list.stream(),list1.stream())
                .forEach(s->System.out.println(s));*/

    }
}
